package edu.hitsz.prop;

import edu.hitsz.aircraft.EnemyAircraft;
import edu.hitsz.aircraft.HeroAircraft;
import edu.hitsz.application.Game;
import edu.hitsz.basic.EnemyObject;
import edu.hitsz.thread.MusicThread;

import java.util.ArrayList;
import java.util.List;

public class BombProp extends BaseProp {
    private static ArrayList<EnemyObject> enemyList = new ArrayList<EnemyObject>();;

    public static void addEnemy(EnemyObject enemyObject) {
        enemyList.add(enemyObject);
    }

    public static void addEnemy(List<EnemyObject> enemyObjects) {
        for (EnemyObject enemyObject: enemyObjects) {
            addEnemy(enemyObject);
        }
    }

    public static void removeEnemy(EnemyObject enemyObject) {
        enemyList.remove(enemyObject);
    }

    public void bombAllEnemy() {
        for(EnemyObject enemyObject: enemyList) {
            enemyObject.bomb();
        }
    }

    public BombProp(int locationX, int locationY, int speedX, int speedY) {
        super(locationX, locationY, speedX, speedY);
    }

    public void Active(HeroAircraft heroAircraft) {
        System.out.println("BombSupply active!");
        get_supply_sound();
        if (Game.music == 1) {
            new MusicThread("src/videos/bomb_explosion.wav").start();
        }
        bombAllEnemy();
        vanish();
    }
}
